﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

//Tal
namespace InformationExtraction
{
    class BornInProcess : ExtractorProcess
    {
        public override void Execute(Person person, Page page)
        {
            //((\w+ )*? \w+, \w+)

            if (page.PlainText.IndexOf("Born in", 0, StringComparison.OrdinalIgnoreCase) != -1)
            {
                int i = 0;
                i++;
            }

            //(, (\S+ )* \S+)?)
            //([^,.]*(( |), [^,.]*?)?)
            //Regex regex = new Regex(@"Born in ([^.,]+)(\bon\b|\bto\b|\bin\b|\band\b|,|.)", RegexOptions.IgnoreCase);
            //MatchCollection mc = regex.Matches(page.PlainText);
            Regex regex = new Regex(@"Born/\S+ in/\S+ ((\S+/NNP )*\S+/NNP)", RegexOptions.IgnoreCase);
            MatchCollection mc = regex.Matches(page.RawContent);
            if (mc.Count > 0)
            {
                person.BornIn = Extractor.StripPos(mc[0].Groups[1].Value);/*
                if (person.BornIn[person.BornIn.Length - 1] == ' ')
                    person.BornIn = person.BornIn.Substring(0, person.BornIn.Length - 1);
                if (person.BornIn.Length > 30)
                    person.BornIn = person.BornIn.Substring(0, 30);
                int x;*/
            }
        }
    }
}
